package com.eliza.client

import com.eliza.client.route.*
import io.github.flaxoos.ktor.server.plugins.ratelimiter.RateLimiting
import io.github.flaxoos.ktor.server.plugins.ratelimiter.implementations.TokenBucket
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import kotlin.time.Duration.Companion.seconds

fun main(args: Array<String>) {
    println("Starting server")
    args.forEach { println(it) }
//    io.ktor.server.netty.EngineMain.main(args)
    embeddedServer(Netty, port = 8080) {
        install(RateLimiting) {
            rateLimiter {
                type = TokenBucket::class
                capacity = 10
                rate = 10.seconds
            }
        }
        module()
        // ...
    }.start(wait = true)
}


fun Application.module() {
    //    configureSecurity()
    configureSerialization()
    validation()
    limiter()
//    configureMonitoring()
//    configureDatabases()
//    configureFrameworks()
//    configureSockets()
//    configureAdministration()
    configureFile()
    configureHTTP()

}
